<?php
session_start();
require_once 'config.php';
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <script>
            var ROOT_ADDRESS = '<?php echo ROOT_ADDRESS; ?>';
        </script>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script src="includes/js/main.js"></script>
    </head>
    <body>
        <div id="lightBox" style="width:100%;height:100%;color:#000;opacity:0.5;display:none;z-index:999;position:absolute;"></div>
        <div id="top"><?php require_once 'view/top.php'; ?></div>
        <div id="content">
            <?php
            if (empty($_SESSION['user'])) {
                $_REQUEST['flag'] = 'logout';
                include 'control/generalControl.php';
                unset($_REQUEST['flag']);
                if (!empty($_REQUEST['pageName']) || !empty($_REQUEST['flag']))
                    header('Location: ' . ROOT_ADDRESS);
                ?>
                <div id="loginPanel">
                    <div>Login</div>
                    <div>
                        <form id="formLogin">
                            <table>
                                <tr>
                                    <td><label for="#username">E-mail: </label></td>
                                    <td><input type="text" name="username" id="username"/></td>
                                </tr>
                                <tr>
                                    <td><label for="#password">Senha: </label></td>
                                    <td><input type="password" name="password" id="password"/></td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center"><input type="button" name="btnLogin" id="btnLogin" value="Entrar" onClick="login()"/></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <?php
            } else {
                if (empty($_REQUEST['pageName']) || empty($_REQUEST['flag'])) {
                    header('Location: ' . ROOT_ADDRESS . '?flag=goToPage&pageName=home');
                } else {
                    include 'control/generalControl.php';
                }
            }
            ?>
        </div>
        <div id="footer"></div>
    </body>
</html>